import req from '@/api/http.js'

import { useLocalData, knowData } from '../../../public/mock/know'
/** 获取知识图谱节点信息(选择框数据) */
export const getKnowledgeGraph = params =>
  req('get', '/ybgl/zstp/nodeList', params)

/** 新增知识图谱节点,id一致则为修改 */
export const saveKnowledgeGraph = params =>
  req('post', '/ybgl/zstp/saveNode', params)

/** 获取知识图谱所有节点信息 */
export const getKnowledgeGraphAll = params => {
  if (useLocalData) {
    return Promise.resolve(knowData())
  } else {
    return req('get', '/ybgl/zstp/allNode', params)
  }
}

/** 新增知识图谱关系 */
export const saveKnowledgeGraphRelation = params =>
  req('post', '/ybgl/zstp/createEdge', params)

/** 删除知识图谱节点 */
export const deleteKnowledgeGraph = data =>
  req('post', '/ybgl/zstp/deleteNode', data)

/** 删除知识图谱关系 */
export const deleteKnowledgeGraphRelation = data =>
  req('post', '/ybgl/zstp/deleteEdge', data)

/** 保存节点位置 */
export const saveNodeCoordinate = data =>
  req('post', '/ybgl/zstp/saveNode', data)
/** 导入知识图谱 */
export const importKnowledgeGraph = data =>
  req('post', '/ybgl/zstp/analysis/import', data)
/** 保存导入的知识图谱信息 */
export const saveImportKnowledgeGraph = data =>
  req('post', '/ybgl/zstp/importZstp', data)

/** 获取配置的节点下拉框选项(选择框数据) */
export const getNodeInfoSelect = params =>
  req('get', '/ybgl/sys-user/dict', params)

